{% extends "base3366.html" %}
{% load comments %}
{% load humanize %}

{% block title %}{{ page.title }}{% endblock %}

{% block maincontent %}

{% get_comment_count for page as comment_count %}
{% get_comment_list for page as comment_list %}

{{ page.chrome_header }}

<i>Last updated {{ page.updated|naturalday }}. {{ comment_count }} comments.
</i>

<p>{{ page.body|safe }}</p>


{% if artifacts %}
<h2>Files:</h2>
<table class="bd-table">
{% for artifact in artifacts %}
	<tr>
		<td width="40px">
			<a href="{{ artifact.get_absolute_url }}">
				<img src="{{ artifact.artifact.get_mime_url }}" alt="" width="48px" height="48px">
			</a>
		</td>
		<td>
			<h3><a href="{{ artifact.get_absolute_url }}">{{ artifact.artifact.title }}</a></h3>
			{{ artifact.artifact.file.size|intcomma }} bytes, Uploaded {{artifact.artifact.updated|timesince }} ago
		</td>
	</tr>
{% endfor %}
</table>
{% endif %}

{% if page.assignment_set.all %}
<h2>Submitted to:</h2>
<ul>
{% for assignment in page.assignment_set.all %}
	<li><a href='{{ assignment.get_absolute_url }}'>{{ assignment.group.title }}</a>:
		<a href='{{ assignment.get_absolute_url }}'>{{ assignment }}</a>
{% endfor %}
</ul>
{% endif %}
<br/>


{% if comment_count %}
<h2 id="comments">Comments:</h2>
{% endif %}
{% for comment in comment_list %}
	<div class="comment_{% cycle odd,even %}" id="c{{ comment.id }}">
		<span class="comnum"><a id="c{{ comment.id }}" href="#c{{ comment.id }}">#{{ forloop.counter }}</a></span>
		<b>{% firstof comment.user.first_name comment.user_name %}</b>,
		{{ comment.submit_date|date:"F j, Y" }} at {{ comment.submit_date|date:"P" }}</p>
		{{ comment.comment|escape|urlizetrunc:40|linebreaks }}
	</div>
{% endfor %}

{% get_comment_form for page as form %}
	{% if request.user.is_authenticated %}
		<h2>Post a new comment</h2>
		<form action="{% comment_form_target %}" method="POST">
			{{ form.comment }}
			{{ form.content_type }}
			{{ form.object_pk }}
			{{ form.timestamp }}
			{{ form.security_hash }}
			<input type="hidden" name="next" value="{{ page.get_absolute_url }}" />
			<br/>
			<button type="submit" name="submit">Post Comment</button>
	{% else %}
		<p>You must log in to post a comment</p>
	{% endif %}


{% endblock %}

{% block sidebar %}
<h1>Portfolio
{% ifequal user.username request.user.username %}
<a class="bd-header-link" href="/{{ user.username }}/page/create/">add a new page</a>
{% endifequal %}
</h1>
{{ pagetree|safe }}
{% endblock %}